package org.flowable.pz.entity.vo;

import lombok.Getter;
import lombok.Setter;
import org.flowable.pz.exception.FlowableCustomException;

/**
 * 分页参数
 * */
@Setter
@Getter
public abstract class FlowablePageQueryVo<T extends FlowablePageQueryVo<T>> {

    //页码
    private Integer pageIndex;

    //每页条数
    private Integer pageSize;

    /**
     * 构建一个基础的查询条件
     * 默认第一页，查询十条记录
     */
    public static <T extends FlowablePageQueryVo<T>> T base(Class<T> clazz) {
        try {
            T instance = clazz.newInstance();
            instance.setPageIndex(1);
            instance.setPageSize(10);
            return instance;
        }catch (InstantiationException | IllegalAccessException e){
            throw new FlowableCustomException("实例化 FlowablePageQueryVo 实例异常！");
        }
    }

    public FlowablePageQueryVo(){
        this.pageIndex = 1;
        this.pageSize = 10;
    }
    public FlowablePageQueryVo(Integer pageIndex, Integer pageSize){
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
    }

}
